package com.ruix.app.model;

import android.text.TextUtils;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by hadexs on 2017/4/13.
 */

public class User implements Serializable {

    private String ID;
    private String name;
    private String mobie;
    private String avatar;
    private String company;
    private String position;
    private String locate;
    private String birthday;
    private String money;
    private int gender;
    private String email;
    private boolean hasLogin;
    private String role;//角色
    private boolean prohibited;
    private boolean loginHX;

    public User parse(JSONObject object) {
        if (object != null) {
            ID = object.optString("id", "");
            name = object.optString("name", "");
            mobie = object.optString("mobie", "");
            avatar = object.optString("avatar", "");
            company = object.optString("company", "");
            position = object.optString("position", "");
            locate = object.optString("locate", "");
            birthday = object.optString("birthday", "");
            gender = object.optInt("sex", 1);
            email = object.optString("email", "");
            money = object.optString("money", "");
        }
        return this;
    }


    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMobie() {
        return mobie;
    }

    public void setMobie(String mobie) {
        this.mobie = mobie;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getLocate() {
        return locate;
    }

    public void setLocate(String locate) {
        this.locate = locate;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public boolean isHasLogin() {
        return hasLogin;
    }

    public void setHasLogin(boolean hasLogin) {
        this.hasLogin = hasLogin;
    }

    public String getRole() {
//        return "1";
        return role;
    }

    public boolean isStudent() {
        return "50".equals(role);
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }

    public boolean hasPurse(){
        if (!TextUtils.isEmpty(money) && Integer.parseInt(money) > 0){
            return true;
        }
        return false;
    }


    public boolean isProhibited() {
        return prohibited;
    }

    public void setProhibited(boolean prohibited) {
        this.prohibited = prohibited;
    }



    public boolean isLoginHX() {
        return loginHX;
    }



    public void setLoginHX(boolean loginHX) {
        this.loginHX = loginHX;
    }


    public boolean isImportInfo() {
        if (!TextUtils.isEmpty(getPosition()) && !"null".equals(getPosition())) {
            return true;
        }
        return false;
    }

    @Override
    public String toString() {
        return "User{" +
                "ID='" + ID + '\'' +
                ", name='" + name + '\'' +
                ", mobie='" + mobie + '\'' +
                ", avatar='" + avatar + '\'' +
                ", company='" + company + '\'' +
                ", position='" + position + '\'' +
                ", locate='" + locate + '\'' +
                ", birthday='" + birthday + '\'' +
                ", gender=" + gender +
                ", email='" + email + '\'' +
                ", hasLogin=" + hasLogin +
                ", role='" + role + '\'' +
                ", prohibited=" + prohibited +
                ", loginHX=" + loginHX +
                '}';
    }
}
